for i in range(self.m):
    for j in range(self.n):
        if grid[i][j] != 0:
            gold_collected = self.dfs(grid, i, j)
            if gold_collected > max_gold:
                max_gold = gold_collected
return max_gold